using System;
using System.Diagnostics;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
namespace MicroMsg.UI.UserContrl
{
	public class CustomSmileyButton : Button
	{
		private Image NormalImage;
		public Image DeleteFlagImage;
		private int indexInPage;
		private bool isShowDeleteFlag;
		public static readonly DependencyProperty ImgWProperty = DependencyProperty.Register("ImgW", typeof(double), typeof(CustomSmileyButton), new PropertyMetadata(32.0, new PropertyChangedCallback(CustomSmileyButton.OnImgWChanged)));
		public static readonly DependencyProperty ImgHProperty = DependencyProperty.Register("ImgH", typeof(double), typeof(CustomSmileyButton), new PropertyMetadata(32.0, new PropertyChangedCallback(CustomSmileyButton.OnImgHChanged)));
		public static readonly DependencyProperty SourceProperty = DependencyProperty.Register("Source", typeof(ImageSource), typeof(CustomSmileyButton), new PropertyMetadata(null, new PropertyChangedCallback(CustomSmileyButton.OnSourceChanged)));
		private bool _contentLoaded;
		public double ImgW
		{
			get
			{
				return (double)base.GetValue(CustomSmileyButton.ImgWProperty);
			}
			set
			{
				base.SetValue(CustomSmileyButton.ImgWProperty, value);
			}
		}
		public double ImgH
		{
			get
			{
				return (double)base.GetValue(CustomSmileyButton.ImgHProperty);
			}
			set
			{
				base.SetValue(CustomSmileyButton.ImgHProperty, value);
			}
		}
		public ImageSource Source
		{
			get
			{
				return (ImageSource)base.GetValue(CustomSmileyButton.SourceProperty);
			}
			set
			{
				base.SetValue(CustomSmileyButton.SourceProperty, value);
			}
		}
		public CustomSmileyButton(ImageSource bmpImg)
		{
			this.InitializeComponent();
			this.Source = bmpImg;
		}
		public CustomSmileyButton()
		{
			this.InitializeComponent();
		}
		public override void OnApplyTemplate()
		{
			base.OnApplyTemplate();
			this.NormalImage = (base.GetTemplateChild("NormalImage") as Image);
			this.DeleteFlagImage = (base.GetTemplateChild("DeleteFlagImage") as Image);
			if (this.isShowDeleteFlag)
			{
				this.DeleteFlagImage.set_Visibility(0);
			}
			this.NormalImage.set_Tag(this.indexInPage);
			this.RefreshImgSource();
		}
		public void SetIndex(int index)
		{
			this.indexInPage = index;
			if (this.NormalImage != null)
			{
				this.NormalImage.set_Tag(this.indexInPage);
			}
		}
		public void showDeleteFlag()
		{
			this.isShowDeleteFlag = true;
			if (this.DeleteFlagImage != null)
			{
				this.DeleteFlagImage.set_Visibility(0);
			}
		}
		public void hideDeleteFlag()
		{
			this.isShowDeleteFlag = false;
			if (this.DeleteFlagImage != null)
			{
				this.DeleteFlagImage.set_Visibility(1);
			}
		}
		private static void OnImgWChanged(DependencyObject dependencyObject_0, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs_0)
		{
			((CustomSmileyButton)dependencyObject_0).OnImgWChanged(dependencyPropertyChangedEventArgs_0);
		}
		protected virtual void OnImgWChanged(DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs_0)
		{
		}
		private static void OnImgHChanged(DependencyObject dependencyObject_0, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs_0)
		{
			((CustomSmileyButton)dependencyObject_0).OnImgHChanged(dependencyPropertyChangedEventArgs_0);
		}
		protected virtual void OnImgHChanged(DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs_0)
		{
		}
		private static void OnSourceChanged(DependencyObject dependencyObject_0, DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs_0)
		{
			((CustomSmileyButton)dependencyObject_0).OnSourceChanged(dependencyPropertyChangedEventArgs_0);
		}
		protected virtual void OnSourceChanged(DependencyPropertyChangedEventArgs dependencyPropertyChangedEventArgs_0)
		{
			this.RefreshImgSource();
		}
		private void RefreshImgSource()
		{
			if (this.NormalImage == null)
			{
				return;
			}
			if (this.NormalImage.get_Source() != this.Source)
			{
				this.NormalImage.set_Source(this.Source);
			}
		}
		[DebuggerNonUserCode]
		public void InitializeComponent()
		{
			if (this._contentLoaded)
			{
				return;
			}
			this._contentLoaded = true;
			Application.LoadComponent(this, new Uri("/MicroMsg;component/Source/UI/Chat/CustomSmileyButton.xaml", 2));
		}
	}
}
